import urllib.request
import re

def ip_num(num=3):
    url='https://www.kuaidaili.com/free/'
    response = urllib.request.urlopen(url)
    html=response.read().decode('utf-8')
    list1=[]
    list2=[]
    list3=[]
    a=0
    for i in range(num):
        b=re.search(r'((([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5])\.){3}([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5]))',html[a:]).group()
        c=re.search(r'((([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5])\.){3}([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5]))',html[a:]).span()
        a+=c[1]
        if html[a] == '0':
            a+=1
            b+='0'
            list1.append(b)
        else:
            list1.append(b)
        b1=re.search(r'\d{1,8}',html[a:]).group()
        list2.append(b1)
    for j in range(len(list1)):
        ip=list1[j]+':'+list2[j]
        list3.append(ip)
    return list3
